package org.darkforest.model;


import com.fasterxml.jackson.annotation.JsonIgnore;
import org.darkforest.common.util.Page;
import org.darkforest.common.util.SystemConstant;
import org.darkforest.enums.MemberLevel;
import org.darkforest.enums.MemberType;

import java.math.BigDecimal;
import java.util.Date;

public class Member extends Page{
    private Integer memberId;

    private String memberName;

    private String memberTruename;

    private String memberAvatar;

    private Integer memberSex;

    private Date memberBirthday;

    @JsonIgnore
    private String memberPasswd;
    @JsonIgnore
    private String memberPasswdConfirm;
    @JsonIgnore
    private String memberPaypwd;

    private String memberEmail;

    private Integer memberEmailBind;

    private String memberMobile;

    private Integer memberMobileBind;

    private String memberQq;

    private String memberWw;

    private Integer memberLoginNum;

    private String memberTime;

    private String memberLoginTime;

    private String memberOldLoginTime;

    private String memberLoginIp;

    private String memberOldLoginIp;

    private String memberQqopenid;

    private String memberSinaopenid;
    @JsonIgnore
    private Integer memberPoints;            //会员积分
    @JsonIgnore
    private Integer freezePoints;            //会员冻结积分
    @JsonIgnore
    private BigDecimal memberCoin;                 //增加会员金币余额字段
    @JsonIgnore
    private BigDecimal availablePredeposit;
    @JsonIgnore
    private BigDecimal freezePredeposit;

    private Boolean informAllow;

    private Boolean isBuy;

    private Boolean isAllowtalk;

    private Boolean memberState;

    private Integer memberCredit;

    private Integer memberSnsvisitnum;

    private Integer memberAreaid;

    private Integer memberCityid;

    private Integer memberProvinceid;

    private String memberAreainfo;

    private String memberQuicklink;

    private String memberWxOpenid; //微信用户唯一标识

    private String memberWxNickName; //微信用户昵称

    private Integer memberType;

    private String path;

    private Integer employeeLevel;          //员工等级

    private Integer proxyLevel;             //代理商等级

    private Integer recommendId;            //推荐人编号

    private String recommendName;           //推荐人用户名

    private String proxyPath;               //所属代理商路径

    private Integer proxyId;							//代理商相关id
    private Integer proxyTeamId;

    private Integer memberLevel;

    private BigDecimal memberFreezeCoin;

    private Integer storeId;                //店铺id

    private String memberLevelInfo;         //会员等级信息

    private BigDecimal pvConsume;           //积分消费
    private BigDecimal consumeAmt;          //消费总额

    private Integer companyId;  //公司id


    private String lastLoginTime; //上次登陆时间

    public String getLastLoginTime() {
        return lastLoginTime;
    }

    public void setLastLoginTime(String lastLoginTime) {
        this.lastLoginTime = lastLoginTime;
    }


    private Integer indirect;  //0,直接客户 1.间接客户


    public Integer getIndirect() {
        return indirect;
    }

    public void setIndirect(Integer indirect) {
        this.indirect = indirect;
    }

    public Member() {
    }

    public Member(boolean pageSwitch) {
        super.setPageSwitch(pageSwitch);
    }

    /**
     * 注册登录构造类
     *
     * @param memberName
     * @param memberPasswd
     * @param memberEmail
     */
    public Member(String memberName, String memberPasswd, String memberEmail) {
        this.memberName = memberName;
        this.memberPasswd = memberPasswd;
        this.memberEmail = memberEmail;
    }

    public void setMemberLevelInfo(String memberLevelInfo) {
        this.memberLevelInfo = memberLevelInfo;
    }
    public String getMemberLevelInfo(){
            if (memberLevel==null)
                return "";
            if( memberLevel == SystemConstant.MEMBER_LEVEL_ONE)
                return "V1";
            else if( memberLevel == SystemConstant.MEMBER_LEVEL_TWO)
                return "V2";
            else if( memberLevel == SystemConstant.MEMBER_LEVEL_THREE)
                return "V3";
            else if( memberLevel == SystemConstant.MEMBER_LEVEL_FOUR)
                return "V4";
            else if( memberLevel == SystemConstant.MEMBER_LEVEL_FIVE)
                return "V5";
            else
                return "V0";
    }
    public Integer getStoreId() {
        return storeId;
    }

    public void setStoreId(Integer storeId) {
        this.storeId = storeId;
    }

    public Integer getMemberLevel() {
        return memberLevel;
    }

    public void setMemberLevel(Integer memberLevel) {
        this.memberLevel = memberLevel;
    }

    public String getMemberPasswdConfirm() {
        return memberPasswdConfirm;
    }

    public void setMemberPasswdConfirm(String memberPasswdConfirm) {
        this.memberPasswdConfirm = memberPasswdConfirm;
    }

    public BigDecimal getMemberCoin() {
        return memberCoin;
    }

    public void setMemberCoin(BigDecimal memberCoin) {
        this.memberCoin = memberCoin;
    }

    public Integer getMemberId() {
        return memberId;
    }

    public void setMemberId(Integer memberId) {
        this.memberId = memberId;
    }

    public String getMemberName() {
        return memberName;
    }

    public void setMemberName(String memberName) {
        this.memberName = memberName == null ? null : memberName.trim();
    }

    public String getMemberTruename() {
        return memberTruename;
    }

    public void setMemberTruename(String memberTruename) {
        this.memberTruename = memberTruename == null ? null : memberTruename.trim();
    }

    public String getMemberAvatar() {
        return memberAvatar;
    }

    public void setMemberAvatar(String memberAvatar) {
        this.memberAvatar = memberAvatar == null ? null : memberAvatar.trim();
    }

    public Integer getMemberSex() {
        return memberSex;
    }

    public void setMemberSex(Integer memberSex) {
        this.memberSex = memberSex;
    }

    public Date getMemberBirthday() {
        return memberBirthday;
    }

    public void setMemberBirthday(Date memberBirthday) {
        this.memberBirthday = memberBirthday;
    }

    public String getMemberPasswd() {
        return memberPasswd;
    }

    public void setMemberPasswd(String memberPasswd) {
        this.memberPasswd = memberPasswd == null ? null : memberPasswd.trim();
    }

    public String getMemberPaypwd() {
        return memberPaypwd;
    }

    public void setMemberPaypwd(String memberPaypwd) {
        this.memberPaypwd = memberPaypwd == null ? null : memberPaypwd.trim();
    }

    public String getMemberEmail() {
        return memberEmail;
    }

    public void setMemberEmail(String memberEmail) {
        this.memberEmail = memberEmail == null ? null : memberEmail.trim();
    }

    public Integer getMemberEmailBind() {
        return memberEmailBind;
    }

    public void setMemberEmailBind(Integer memberEmailBind) {
        this.memberEmailBind = memberEmailBind;
    }

    public String getMemberMobile() {
        return memberMobile;
    }

    public void setMemberMobile(String memberMobile) {
        this.memberMobile = memberMobile == null ? null : memberMobile.trim();
    }

    public Integer getMemberMobileBind() {
        return memberMobileBind;
    }

    public void setMemberMobileBind(Integer memberMobileBind) {
        this.memberMobileBind = memberMobileBind;
    }

    public String getMemberQq() {
        return memberQq;
    }

    public void setMemberQq(String memberQq) {
        this.memberQq = memberQq == null ? null : memberQq.trim();
    }

    public String getMemberWw() {
        return memberWw;
    }

    public void setMemberWw(String memberWw) {
        this.memberWw = memberWw == null ? null : memberWw.trim();
    }

    public Integer getMemberLoginNum() {
        return memberLoginNum;
    }

    public void setMemberLoginNum(Integer memberLoginNum) {
        this.memberLoginNum = memberLoginNum;
    }

    public String getMemberTime() {
        return memberTime;
    }

    public void setMemberTime(String memberTime) {
        this.memberTime = memberTime == null ? null : memberTime.trim();
    }

    public String getMemberLoginTime() {
        return memberLoginTime;
    }

    public void setMemberLoginTime(String memberLoginTime) {
        this.memberLoginTime = memberLoginTime == null ? null : memberLoginTime.trim();
    }

    public String getMemberOldLoginTime() {
        return memberOldLoginTime;
    }

    public void setMemberOldLoginTime(String memberOldLoginTime) {
        this.memberOldLoginTime = memberOldLoginTime == null ? null : memberOldLoginTime.trim();
    }

    public String getMemberLoginIp() {
        return memberLoginIp;
    }

    public void setMemberLoginIp(String memberLoginIp) {
        this.memberLoginIp = memberLoginIp == null ? null : memberLoginIp.trim();
    }

    public String getMemberOldLoginIp() {
        return memberOldLoginIp;
    }

    public void setMemberOldLoginIp(String memberOldLoginIp) {
        this.memberOldLoginIp = memberOldLoginIp == null ? null : memberOldLoginIp.trim();
    }

    public String getMemberQqopenid() {
        return memberQqopenid;
    }

    public void setMemberQqopenid(String memberQqopenid) {
        this.memberQqopenid = memberQqopenid == null ? null : memberQqopenid.trim();
    }

    public String getMemberSinaopenid() {
        return memberSinaopenid;
    }

    public void setMemberSinaopenid(String memberSinaopenid) {
        this.memberSinaopenid = memberSinaopenid == null ? null : memberSinaopenid.trim();
    }

    public Integer getMemberPoints() {
        return memberPoints;
    }

    public void setMemberPoints(Integer memberPoints) {
        this.memberPoints = memberPoints;
    }

    public Integer getFreezePoints() {
        return freezePoints;
    }

    public void setFreezePoints(Integer freezePoints) {
        this.freezePoints = freezePoints;
    }

    public void addMemberPoints(Integer pointsToBeAdd) {
        if (pointsToBeAdd == null) {
            return;
        }

        if (this.getMemberPoints() == null) {
            this.setMemberPoints(pointsToBeAdd);
        } else {
            this.setMemberPoints(this.getMemberPoints() + pointsToBeAdd);
        }
    }

    public BigDecimal getAvailablePredeposit() {
        return availablePredeposit;
    }

    public void setAvailablePredeposit(BigDecimal availablePredeposit) {
        this.availablePredeposit = availablePredeposit;
    }

    public BigDecimal getFreezePredeposit() {
        return freezePredeposit;
    }

    public void setFreezePredeposit(BigDecimal freezePredeposit) {
        this.freezePredeposit = freezePredeposit;
    }

    public Boolean getInformAllow() {
        return informAllow;
    }

    public void setInformAllow(Boolean informAllow) {
        this.informAllow = informAllow;
    }

    public Boolean getIsBuy() {
        return isBuy;
    }

    public void setIsBuy(Boolean isBuy) {
        this.isBuy = isBuy;
    }

    public Boolean getIsAllowtalk() {
        return isAllowtalk;
    }

    public void setIsAllowtalk(Boolean isAllowtalk) {
        this.isAllowtalk = isAllowtalk;
    }

    public Boolean getMemberState() {
        return memberState;
    }

    public void setMemberState(Boolean memberState) {
        this.memberState = memberState;
    }

    public Integer getMemberCredit() {
        return memberCredit;
    }

    public void setMemberCredit(Integer memberCredit) {
        this.memberCredit = memberCredit;
    }

    public Integer getMemberSnsvisitnum() {
        return memberSnsvisitnum;
    }

    public void setMemberSnsvisitnum(Integer memberSnsvisitnum) {
        this.memberSnsvisitnum = memberSnsvisitnum;
    }

    public Integer getMemberAreaid() {
        return memberAreaid;
    }

    public void setMemberAreaid(Integer memberAreaid) {
        this.memberAreaid = memberAreaid;
    }

    public Integer getMemberCityid() {
        return memberCityid;
    }

    public void setMemberCityid(Integer memberCityid) {
        this.memberCityid = memberCityid;
    }

    public Integer getMemberProvinceid() {
        return memberProvinceid;
    }

    public void setMemberProvinceid(Integer memberProvinceid) {
        this.memberProvinceid = memberProvinceid;
    }

    public String getMemberAreainfo() {
        return memberAreainfo;
    }

    public void setMemberAreainfo(String memberAreainfo) {
        this.memberAreainfo = memberAreainfo == null ? null : memberAreainfo.trim();
    }

    public String getMemberQuicklink() {
        return memberQuicklink;
    }

    public void setMemberQuicklink(String memberQuicklink) {
        this.memberQuicklink = memberQuicklink == null ? null : memberQuicklink.trim();
    }

    public String getMemberWxOpenid() {
        return memberWxOpenid;
    }

    public void setMemberWxOpenid(String memberWxOpenid) {
        this.memberWxOpenid = memberWxOpenid;
    }

    public String getMemberWxNickName() {
        return memberWxNickName;
    }

    public void setMemberWxNickName(String memberWxNickName) {
        this.memberWxNickName = memberWxNickName;
    }


    public Integer getMemberType() {
        return memberType;
    }
    public void setMemberType(Integer memberType) {
        this.memberType = memberType;
    }

    public MemberType getMemberTypeEnum() {
        MemberType memberType1 = MemberType.getMemberType(this.memberType);
        return memberType1 == null ? MemberType.NORMAL : memberType1;
    }
    public void setMemberTypeEnum(MemberType memberType) {
        this.memberType = memberType.getType();
    }

//    public MemberType getMemberTypeEnum() {
//        return memberType == null ? MemberType.NORMAL : memberType;
//    }
//
//    public Integer getMemberType() {
//        return memberType == null ? MemberType.NORMAL.getType() : memberType.getType();
//    }
//
//    public void setMemberType(MemberType memberType) {
//        this.memberType = memberType;
//    }

//    public void setMemberType(Integer memberType) {
//        if (memberType == null) {
//            this.memberType = MemberType.NORMAL;
//            return;
//        }
//        this.memberType = MemberType.getMemberType(memberType);
//    }

    public String getMemberTypeStr(){
        if(memberType == MemberType.EMPLOYEE.getType()){
            return ""+employeeLevel+"级员工";
        }
        if(memberType == MemberType.MERCHANT.getType()){
            return ""+proxyLevel+"级代理商";
        }
        return "普通会员";
    }

    public String getWapMemberTypeStr(){
        if(memberType == MemberType.EMPLOYEE.getType()){
            return "员工";
        }
        if(memberType == MemberType.MERCHANT.getType()){
            String level_cn = "";
            switch (proxyLevel){
                case 1:
                    level_cn = "一";
                    break;
                case 2:
                    level_cn = "二";
                    break;
                case 3:
                    level_cn = "三";
                    break;
            }
            return ""+level_cn+"级代理商";
        }
        return "会员";
    }


    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public Integer getEmployeeLevel() {
        return employeeLevel;
    }

    public void setEmployeeLevel(Integer employeeLevel) {
        this.employeeLevel = employeeLevel;
    }

    public Integer getRecommendId() {
        return recommendId;
    }

    public void setRecommendId(Integer recommendId) {
        this.recommendId = recommendId;
    }

    public String getRecommendName() {
        return recommendName;
    }

    public void setRecommendName(String recommendName) {
        this.recommendName = recommendName;
    }

    public String getProxyPath() {
        return proxyPath;
    }

    public void setProxyPath(String proxyPath) {
        this.proxyPath = proxyPath;
    }

    public Integer getProxyLevel() {
        return proxyLevel;
    }

    public void setProxyLevel(Integer proxyLevel) {
        this.proxyLevel = proxyLevel;
    }

    public Integer getProxyId() {
        return proxyId;
    }

    public void setProxyId(Integer proxyId) {
        this.proxyId = proxyId;
    }

    public Integer getProxyTeamId() {
        return proxyTeamId;
    }

    public void setProxyTeamId(Integer proxyTeamId) {
        this.proxyTeamId = proxyTeamId;
    }

    public BigDecimal getMemberFreezeCoin() {
        return memberFreezeCoin;
    }

    public void setMemberFreezeCoin(BigDecimal memberFreezeCoin) {
        this.memberFreezeCoin = memberFreezeCoin;
    }

    public BigDecimal getPvConsume() {
        return pvConsume;
    }

    public void setPvConsume(BigDecimal pvConsume) {
        this.pvConsume = pvConsume;
    }

    public BigDecimal getConsumeAmt() {
        return consumeAmt;
    }

    public void setConsumeAmt(BigDecimal consumeAmt) {
        this.consumeAmt = consumeAmt;
    }

    public static Member createDefaultMember() {
        Member member = new Member();
        member.setMemberPasswd("");
        member.setMemberPaypwd("");
        member.setMemberEmailBind(0);
        member.setMemberLoginNum(0);
        //member.setMemberTime(DateUtil.toTimeString(new Date()));
        //member.setMemberLoginTime(DateUtil.toTimeString(new Date()));
        member.setMemberPoints(0);
        member.setAvailablePredeposit(new BigDecimal("0.00"));
        member.setFreezePredeposit(new BigDecimal("0.00"));
        member.setInformAllow(true);
        member.setIsBuy(true);
        member.setIsAllowtalk(true);
        member.setMemberState(true);
        member.setMemberCredit(0);
        member.setMemberSnsvisitnum(0);
        return member;
    }

    @Override
    public String toString() {
        return "Member{" +
                "memberId=" + memberId +
                ", memberName='" + memberName + '\'' +
                ", path='" + path + '\'' +
                ", employeeLevel=" + employeeLevel +
                ", memberType=" + memberType +
                ", memberWxNickName='" + memberWxNickName + '\'' +
                ", memberEmail='" + memberEmail + '\'' +
                ", memberMobile='" + memberMobile + '\'' +
                '}';
    }

    public Integer getCompanyId() {
        return companyId;
    }

    public void setCompanyId(Integer companyId) {
        this.companyId = companyId;
    }
}